package org.jeecg.modules.fund.job;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.fund.entity.FundList;
import org.jeecg.modules.fund.entity.FundVal;
import org.jeecg.modules.fund.service.IFundListService;
import org.jeecg.modules.fund.service.IFundMovingService;
import org.jeecg.modules.fund.service.IFundValService;
import org.jeecg.modules.fund.util.FundDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
@Deprecated
public class FundValueJob {
    @Autowired
    private IFundListService fundListService;
    @Autowired
    private IFundValService fundValService;
    @Autowired
    private IFundMovingService fundMovingService;

    /**
     * 每周一至五，晚20点至23点，每40分钟执行一次，净值更新任务
     * @throws InterruptedException
     */
    // @Scheduled(cron = "0 0,20,40 19,20,21,22,23,0,1,2,3,4,8 * * *")
    public void execute() throws InterruptedException {
        log.info("执行净值更新任务");
        // 获取自选基金列表
        List<FundList> fundLists = fundListService.list();
        // 遍历基金列表
        fundLists.forEach(item -> {
            // 更新
            fundValService.updateVal(item.getCode(),false);
        });
        log.info("任务结束");
    }
}
